package com.ruoyi.rycc.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.rycc.domain.CcCourseware;
import com.ruoyi.rycc.mapper.CcCoursewareMapper;
import com.ruoyi.rycc.service.ICcCoursewareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 课件Service业务层处理
 *
 * @author antg
 * @date 2021-09-06
 */
@Service
public class CcCoursewareServiceImpl implements ICcCoursewareService {
    @Autowired
    private CcCoursewareMapper ccCoursewareMapper;

    /**
     * 查询课件
     *
     * @param id 课件主键
     * @return 课件
     */
    @Override
    public CcCourseware selectCcCoursewareById(Long id) {
        return ccCoursewareMapper.selectCcCoursewareById(id);
    }

    /**
     * 查询课件列表
     *
     * @param ccCourseware 课件
     * @return 课件
     */
    @Override
    public List<CcCourseware> selectCcCoursewareList(CcCourseware ccCourseware) {
        return ccCoursewareMapper.selectCcCoursewareList(ccCourseware);
    }

    /**
     * 新增课件
     *
     * @param ccCourseware 课件
     * @return 结果
     */
    @Override
    public int insertCcCourseware(CcCourseware ccCourseware) {
        ccCourseware.setCreateTime(DateUtils.getNowDate());
        return ccCoursewareMapper.insertCcCourseware(ccCourseware);
    }

    /**
     * 修改课件
     *
     * @param ccCourseware 课件
     * @return 结果
     */
    @Override
    public int updateCcCourseware(CcCourseware ccCourseware) {
        ccCourseware.setUpdateTime(DateUtils.getNowDate());
        return ccCoursewareMapper.updateCcCourseware(ccCourseware);
    }

    /**
     * 批量删除课件
     *
     * @param ids 需要删除的课件主键
     * @return 结果
     */
    @Override
    public int deleteCcCoursewareByIds(String ids) {
        return ccCoursewareMapper.deleteCcCoursewareByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除课件信息
     *
     * @param id 课件主键
     * @return 结果
     */
    @Override
    public int deleteCcCoursewareById(Long id) {
        return ccCoursewareMapper.deleteCcCoursewareById(id);
    }
}
